package com.ticket.sass.ticketserver.dto.input;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;

/**
 * @author 朱其鹏
 * @date 2024/5/18 11:00
 */
public class SeatLockInput {
    @NotNull(message = "outLockNo 必传参数")
    @NotBlank(message = "outLockNo 不能为空")
    private String outLockNo;

    @NotNull(message = "sessionCode 必传参数")
    @NotBlank(message = "sessionCode 不能为空")
    private String sessionCode;

    @NotNull(message = "scheduleKey 必传参数")
    private String scheduleKey;

    @NotNull(message = "seatList 必传参数")
    @NotEmpty(message = "seatList 不能为空")
    @Valid
    private Seat[] seatList;

    public @NotNull(message = "scheduleCode 必传参数") @NotBlank(message = "scheduleCode 不能为空") String getSessionCode() {
        return sessionCode;
    }

    public void setSessionCode(@NotNull(message = "scheduleCode 必传参数") @NotBlank(message = "scheduleCode 不能为空") String sessionCode) {
        this.sessionCode = sessionCode;
    }

    public String getScheduleKey() {
        return scheduleKey;
    }

    public void setScheduleKey(String scheduleKey) {
        this.scheduleKey = scheduleKey;
    }

    public @NotNull(message = "seatList 必传参数") @NotEmpty(message = "seatList 不能为空") @Valid Seat[] getSeatList() {
        return seatList;
    }

    public void setSeatList(@NotNull(message = "seatList 必传参数") @NotEmpty(message = "seatList 不能为空") @Valid Seat[] seatList) {
        this.seatList = seatList;
    }

    public @NotNull(message = "lockId 必传参数") @NotBlank(message = "lockId 不能为空") String getOutLockNo() {
        return outLockNo;
    }

    public void setOutLockNo(@NotNull(message = "lockId 必传参数") @NotBlank(message = "lockId 不能为空") String outLockNo) {
        this.outLockNo = outLockNo;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("SeatLockInput{");
        sb.append("outLockNo='").append(outLockNo).append('\'');
        sb.append(", sessionCode='").append(sessionCode).append('\'');
        sb.append(", scheduleKey='").append(scheduleKey).append('\'');
        sb.append(", seatList=").append(Arrays.toString(seatList));
        sb.append('}');
        return sb.toString();
    }

    public static class Seat {
        @NotNull(message = "code 必传参数")
        @NotEmpty(message = "code 不能为空")
        private String code;

        @NotNull(message = "id 必传参数")
        @NotEmpty(message = "id 不能为空")
        private String id;

        public @NotNull(message = "code 必传参数") @NotEmpty(message = "code 不能为空") String getCode() {
            return code;
        }

        public void setCode(@NotNull(message = "code 必传参数") @NotEmpty(message = "code 不能为空") String code) {
            this.code = code;
        }

        public @NotNull(message = "id 必传参数") @NotEmpty(message = "id 不能为空") String getId() {
            return id;
        }

        public void setId(@NotNull(message = "id 必传参数") @NotEmpty(message = "id 不能为空") String id) {
            this.id = id;
        }

        @Override
        public String toString() {
            final StringBuilder sb = new StringBuilder("Seat{");
            sb.append("code='").append(code).append('\'');
            sb.append(", id='").append(id).append('\'');
            sb.append('}');
            return sb.toString();
        }
    }
}
